package com.itheima.tanhua.controller;

import com.itheima.tanhua.service.AnalysisByDayService;
import com.itheima.tanhua.vo.AnalysisByDayVo;
import com.itheima.tanhua.vo.DistributionVo;
import com.itheima.tanhua.vo.YearItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("dashboard")
public class DashboardController {
    @Autowired
    private AnalysisByDayService analysisByDayService;

    /**
     * 概要统计信息
     *
     * @return
     */
    @GetMapping("summary")
    public ResponseEntity summary() {
        AnalysisByDayVo vo = analysisByDayService.summary();
        return ResponseEntity.ok(vo);
    }

    /**
     * 概要统计信息
     *
     * @return
     */
    @GetMapping("users")
    public ResponseEntity usersInfo(String sd, String ed, Integer type) {
        YearItemVo vo = analysisByDayService.usersInfo(sd, ed, type);

        return ResponseEntity.ok(null);
    }

    /**
     * 注册用户分布，行业top、年龄、性别、地区
     *
     * @return
     */
    @GetMapping("distribution")
    public ResponseEntity distribution(String sd, String ed) {
        DistributionVo vo = analysisByDayService.distribution(sd, ed);
        return ResponseEntity.ok(vo);
    }
}
